package com.example.lexiangbackend.dto;

import com.example.lexiangbackend.entity.Favorite;
import com.example.lexiangbackend.entity.Music;
import com.example.lexiangbackend.entity.MusicCategory;

import java.time.LocalDateTime;

public class FavoriteResponse {
    private Long favoriteId;
    private LocalDateTime favoriteTime;
    private MusicInfo music;
    
    public static class MusicInfo {
        private Long musicId;
        private String name;
        private String singer;
        private String title;
        private String artist;
        private String album;
        private Integer duration;
        private String coverPath;
        private String filePath;
        private CategoryInfo category;
        
        public static class CategoryInfo {
            private Long categoryId;
            private String name;
            private String color;
            private String icon;
            
            public CategoryInfo(MusicCategory category) {
                if (category != null) {
                    this.categoryId = category.getCategoryId();
                    this.name = category.getName();
                    this.color = category.getColor();
                    this.icon = category.getIcon();
                }
            }
            
            // Getters and setters
            public Long getCategoryId() { return categoryId; }
            public void setCategoryId(Long categoryId) { this.categoryId = categoryId; }
            public String getName() { return name; }
            public void setName(String name) { this.name = name; }
            public String getColor() { return color; }
            public void setColor(String color) { this.color = color; }
            public String getIcon() { return icon; }
            public void setIcon(String icon) { this.icon = icon; }
        }
        
        public MusicInfo(Music music) {
            if (music != null) {
                this.musicId = music.getMusicId();
                this.name = music.getName();
                this.singer = music.getSinger();
                this.title = music.getTitle();
                this.artist = music.getArtist();
                this.album = music.getAlbum();
                this.duration = music.getDuration();
                this.coverPath = music.getCoverPath();
                this.filePath = music.getFilePath();
                this.category = new CategoryInfo(music.getCategory());
            }
        }
        
        // Getters and setters
        public Long getMusicId() { return musicId; }
        public void setMusicId(Long musicId) { this.musicId = musicId; }
        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        public String getSinger() { return singer; }
        public void setSinger(String singer) { this.singer = singer; }
        public String getTitle() { return title; }
        public void setTitle(String title) { this.title = title; }
        public String getArtist() { return artist; }
        public void setArtist(String artist) { this.artist = artist; }
        public String getAlbum() { return album; }
        public void setAlbum(String album) { this.album = album; }
        public Integer getDuration() { return duration; }
        public void setDuration(Integer duration) { this.duration = duration; }
        public String getCoverPath() { return coverPath; }
        public void setCoverPath(String coverPath) { this.coverPath = coverPath; }
        public String getFilePath() { return filePath; }
        public void setFilePath(String filePath) { this.filePath = filePath; }
        public CategoryInfo getCategory() { return category; }
        public void setCategory(CategoryInfo category) { this.category = category; }
    }
    
    public FavoriteResponse(Favorite favorite) {
        if (favorite != null) {
            this.favoriteId = favorite.getFavoriteId();
            this.favoriteTime = favorite.getFavoriteTime();
            this.music = new MusicInfo(favorite.getMusic());
        }
    }
    
    // Getters and setters
    public Long getFavoriteId() { return favoriteId; }
    public void setFavoriteId(Long favoriteId) { this.favoriteId = favoriteId; }
    public LocalDateTime getFavoriteTime() { return favoriteTime; }
    public void setFavoriteTime(LocalDateTime favoriteTime) { this.favoriteTime = favoriteTime; }
    public MusicInfo getMusic() { return music; }
    public void setMusic(MusicInfo music) { this.music = music; }
} 